# -*- coding: utf-8 -*-
import sys
import collections
sys.path.append("../../quidditas")

import quidditas

class PositionComponent(object):
    """ DOCME """
    def __init__(self, x=0, y=0):
        self.x = x
        self.y = y
        self.rotation = 0

class HealthComponent(object):
    """ DOCME """
    def __init__(self, initial=100):
        self.hp = initial

class VelocityComponent(object):
    """ DOCME """
    def __init__(self, speed=0):
        self.max_speed = speed
        self.current_y = 0
        self.current_x = 0

    def reset_speed(self):
        """ DOCME """
        self.current_speed = self.max_speed

class WeaponComponent(object):
    """ DOCME """
    def __init__(self, dmg, rate):
        self.dmg = dmg
        self.rate = rate

class RenderingComponent(object):
    """ DOCME """
    def __init__(self, image_name=""):
        self.image = image_name
        self.scale = 1
        self.alpha = 1

class WorldGridComponent(object):
    """ Defines a world grid.
    Attributes:
      size - The dimensions of the grid in cells wide,cells high
    """
    def __init__(self, size=(10,10)):
        self.size = size
        self.reset_map()

    def reset_map(self):
        """ Mark all fields as empty. """
        self.grid = [[True for j in xrange(self.size[1])] for i in xrange(self.size[0])]

""" Specifies the possible routes for a map.
    Parameters:
      routes - A tuple of 2-tuples where each pair describes start and finish for a route in grid
      coordinates. """
RouteDefinitionComponent = collections.namedtuple("RouteDefinitionComponent", ["routes"])

class PathFinderComponent(object):
    """ Stores information for pathfinding for an entity.
    Attributes:
      type   - The type of pathfinding 'ground' or 'air'
      target - The target grid cell that the entity wants to reach. 
    """
    def __init__(self, type):
        self.type = type
        self.target = None
        self.route = None

""" Specifies the waves for a map.
Contains a tuple for each wave which contains tuples of wave definitions. """
WaveDefinitionComponent = collections.namedtuple("WaveDefinitionComponent", ["waves"])

class SpawnComponent(object):
    """ A component that spawns entities of a given type. """
    def __init__(self):
        self.type = None
        self.amount = 0
        self.rate = 0
        self.current_timer = 0
        self.hp_multiplicator = 0
        self.route_id = 0

class RouteComponent(object):
    """ A route within a map. Has a start and end cell and specifies the order of cells
    by wich the end can be reached.
    The route is updated against the collision map by a processor to keep it up to date. """
    def __init__(self):
        self.route_id = 0
        self.start = (0,0)
        self.end = (0,0)
        self.cell_order = []

class EntityComponent(object):
    """ A component used for a 'foreign key' like connection to another entity.
    Holds one id of another entity. """
    def __init__(self, entity_id):
        self.entity_id = entity_id